package cn.wolfcode.luowowo.controller;


import cn.wolfcode.luowowo.domain.*;
import cn.wolfcode.luowowo.service.*;
import cn.wolfcode.luowowo.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("destinations")
public class DestinationController {
    @Autowired
    private IRegionService regionService;
    @Autowired
    private IDestinationService destinationService;
    @Autowired
    private IStrategyCatalogService strategyCatalogService;
    @Autowired
    private IStrategyService strategyService;
    @Autowired
    private ITravelService travelService;

    @GetMapping("hotRegion")
    public Object hotRegion(){
        List<Region> list = regionService.queryHot();
        return JsonResult.success(list);
    }


    @GetMapping("search")
    public Object search(String regionId){
        List<Destination> destinations = destinationService.queryByRegionIdFor(regionId);
        return JsonResult.success(destinations);
    }


    @GetMapping("toasts")
    public Object toasts(String destId){
        List<Destination> toast = destinationService.getToast(destId);
        return JsonResult.success(toast);
    }



    @GetMapping("detail")
    public Object detail(String id){
        Destination destination = destinationService.selectOne(id);
        return JsonResult.success(destination);
    }



    @GetMapping("catalogs")
    public Object catalogs(String destId){
        List<StrategyCatalog> catalogs = strategyCatalogService.queryByDestId(destId);
        return JsonResult.success(catalogs);
    }


    @GetMapping("strategies/viewnumTop3")
    public Object SviewnumTop3(String destId){
        List<Strategy> strategies = strategyService.queryViewnumTop3ByDestId(destId);
        return JsonResult.success(strategies);
    }

    @GetMapping("travels/viewnumTop3")
    public Object travelsViewnumTop3(String destId){
        List<Travel> travels = travelService.queryViewnumTop3ByDestId(destId);
        return JsonResult.success(travels);
    }




}
